
// #include "xsdk_config.h"

#include "xapp_config.h"

#if USER_CHECK_ENABLED( GOAL )

#include "xapp_goal.h"

#include "xapp_profile.h"
#include "xapp_osllv.h"

#if USER_CHECK_LOG_ENABLED( GOAL )
#include "log.h"
#define LOG     LOG_INFO 
#define LOG0    LOG_INFO0 
#define LOG1    LOG_INFO1
#define LOG2    LOG_INFO2
#define LOG3    LOG_INFO3
#else 
#define LOG(...) 
#define LOG0(...)
#define LOG1(...)
#define LOG2(...)
#define LOG3(...)
#endif 

static bool m_goal_steps_of_day_is_actived = false; 


void xapp_goal_init(void)
{
    m_goal_steps_of_day_is_actived = false;
}

void xapp_goal_steps_on_change(uint32_t steps)
{
    if( m_goal_steps_of_day_is_actived )
    {
        return;
    }

    const profile_target_step_t* target = xapp_profile_get_target();
    m_goal_steps_of_day_is_actived = steps >= target->day;

    if( m_goal_steps_of_day_is_actived )
    {
        OSLLV_SEND_TAG_EXE( OSLLV_TAG_GOAL_REACH );
    }
}

void xapp_goal_steps_check_dummy(uint32_t steps)
{
    const profile_target_step_t* target = xapp_profile_get_target();
    
    m_goal_steps_of_day_is_actived = steps >= target->day;
}

#endif // !USER_CHECK_ENABLED( GOAL )
